package com.t235.gc.order.service.impl;

import com.t235.gc.entity.HomeRecyclingOrder;
import com.t235.gc.dao.HomeRecyclingOrderDao;
import com.t235.gc.order.service.HomeRecyclingOrderService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 上门回收订单表(HomeRecyclingOrder)表服务实现类
 *
 * @author makejava
 * @since 2021-03-24 08:45:33
 */
@Service("homeRecyclingOrderService")
public class HomeRecyclingOrderServiceImpl implements HomeRecyclingOrderService {
    @Resource
    private HomeRecyclingOrderDao homeRecyclingOrderDao;

    /**
     * 通过ID查询单条数据
     *
     * @param orderid 主键
     * @return 实例对象
     */
    @Override
    public HomeRecyclingOrder queryById(Long orderid) {
        return this.homeRecyclingOrderDao.queryById(orderid);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<HomeRecyclingOrder> queryAllByLimit(int offset, int limit) {
        return this.homeRecyclingOrderDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param homeRecyclingOrder 实例对象
     * @return 实例对象
     */
    @Override
    public HomeRecyclingOrder insert(HomeRecyclingOrder homeRecyclingOrder) {
        this.homeRecyclingOrderDao.insert(homeRecyclingOrder);
        return homeRecyclingOrder;
    }

    /**
     * 修改数据
     *
     * @param homeRecyclingOrder 实例对象
     * @return 实例对象
     */
    @Override
    public HomeRecyclingOrder update(HomeRecyclingOrder homeRecyclingOrder) {
        this.homeRecyclingOrderDao.update(homeRecyclingOrder);
        return this.queryById(homeRecyclingOrder.getOrderid());
    }

    /**
     * 通过主键删除数据
     *
     * @param orderid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long orderid) {
        return this.homeRecyclingOrderDao.deleteById(orderid) > 0;
    }
}
